<?php
	$conn = new mysqli('localhost', 'root', '', 'sevenbits');
	$sql = "SELECT 
			`wdate`.`WDate`,
			`roles`.`RoleName`,
			`roles`.`StartTime`,
			`roles`.`EndTime`,
			`employees`.`EmpFname`,
			`employees`.`EmpLname`,
			`roledate`.`ShiftStatus`,
			`roledate`.`RequestPendingApproval` FROM wdate
		LEFT JOIN `sevenbits`.`roledate` ON `wdate`.`DateID` = `roledate`.`DateID` 
		LEFT JOIN `sevenbits`.`roles` ON `roledate`.`RoleID` = `roles`.`RoleID` 
		LEFT JOIN `sevenbits`.`employees` ON `roledate`.`EmpID` = `employees`.`EmpID`";
	$result = $conn->query($sql);
	// if the $result contains at least one row
	if ($result->num_rows > 0) {
		$arrResults = array();
	  // output data of each row from $result
	  while($row = $result->fetch_assoc()) {
		$arrResults[] = array(
			'WDate' => $row['WDate'],
			'RoleName' => $row['RoleName'],
			'StartTime' => $row['StartTime'],
			'EndTime' => $row['EndTime'],
			'EmpFname' => $row['EmpFname'],
			'EmpLname' => $row['EmpLname'],
			'ShiftStatus' => $row['ShiftStatus'],
			'RequestPendingApproval' => $row['RequestPendingApproval']
			);
	  }
	}
	echo json_encode($arrResults);
?>